<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>书城首页</title>
    <jsp:include page="/WEB-INF/include/base.jsp"></jsp:include>
</head>
<body>
<script type="text/javascript">
    $(function () {
        $("#searchId").click(function () {
            var min = $("[name='min']").val();
            var max = $("[name='max']").val();
            location = "BookClientServlet?method=getPageByPrice&min="+min+"&max="+max;
        });
        $(".addBtn").click(function () {
            var bookId = $(this).val();
            location = "CartServlet?method=addBook2Cart&bookId="+bookId;
            //可能报错的地方
        });
    });
</script>

<div id="header">
    <img class="logo_img" alt="" src="static/img/logo.gif" >
    <span class="wel_word">网上书城</span>
    <jsp:include page="/WEB-INF/include/client_head.jsp"></jsp:include>
</div>

 <div id="main">
    <div id="book">
        <div class="book_cond">
            价格：<input type="text" name="min" value="${param.min}"> 元 - <input type="text" name="max" value="${param.max}"> 元 <button id="searchId">查询</button>
        </div>
<%--两种情况  1.没放书  2.书删除了--%>
            <div style="text-align: center;">
        <c:if test="${not empty sessionScope.cart.map}">
                <span>您的购物车中有${sessionScope.cart.totalCount}件商品</span>
                <div>
                    您刚刚将<span style="color: red">${sessionScope.bookTitle}</span>加入到了购物车中
                </div>
        </c:if>
                <c:if test="${empty sessionScope.cart.map}">
                    <div>
                        主人你的购物车还空空如也哦！
                    </div>
                </c:if>


            </div>

        <c:forEach items="${requestScope.page.list}" var="book">
            <div class="b_list">
                <div class="img_div">
                    <img class="book_img" alt="" src="${pageScope.book.imgPath}" />
                </div>
                <div class="book_info">
                    <div class="book_name">
                        <span class="sp1">书名:</span>
                        <span class="sp2">${pageScope.book.title}</span>
                    </div>
                    <div class="book_author">
                        <span class="sp1">作者:</span>
                        <span class="sp2">${pageScope.book.author}</span>
                    </div>
                    <div class="book_price">
                        <span class="sp1">价格:</span>
                        <span class="sp2">￥${pageScope.book.price}</span>
                    </div>
                    <div class="book_sales">
                        <span class="sp1">销量:</span>
                        <span class="sp2">${pageScope.book.sales}</span>
                    </div>
                    <div class="book_amount">
                        <span class="sp1">库存:</span>
                        <span class="sp2">${pageScope.book.stock}</span>
                    </div>
                    <div class="book_add">
                        <button class="addBtn"   value="${pageScope.book.id}">加入购物车</button>
<%--//报错在添加了value--%>
                    </div>
                </div>
            </div>
        </c:forEach>

    </div>
    <jsp:include page="/WEB-INF/include/page.jsp"></jsp:include>


</div>

<div id="bottom">
		<span>
			尚硅谷书城.Copyright &copy;2015
		</span>
</div>
</body>
</html>